package com.infoland.afanmall.base.activity;

import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Toast;

import com.blankj.utilcode.util.NetworkUtils;
import com.infoland.afanmall.R;
import com.infoland.afanmall.base.util.CacheKit;

import static com.blankj.utilcode.util.CrashUtils.init;

public abstract class BaseCompatActivity extends AppCompatActivity {

    public abstract int setLayout();

    public abstract void init();

    public abstract void initData();

    public Bundle bundle;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(setLayout());
        bundle = this.getIntent().getExtras();
//        CacheKit.INTERNET = NetworkUtils.isAvailableByPing();
        if (CacheKit.INTERNET) {

        } else {
            Toast.makeText(getApplicationContext(), "当前网络断开,请连接后使用", Toast.LENGTH_SHORT).show();
        }
        init();
        initData();
    }

    // 获取控件
    public <T extends View> T $(@IdRes int viewId) {
        return findViewById(viewId);
    }


}
